package org.dudemonkey.thread.p28;

public class TestInterrupt {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                // 这里竟然可以执行！可见 interrupt并非抛异常
                System.out.println("In t1 , the rest code . ");
            }
        };
        System.out.println(t1.getState());
        t1.start();
        System.out.println(t1.getState());

        Thread.sleep(1000);

        t1.interrupt();

        System.out.println(t1.getState());
    }
}
